﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace Experiment.DAL
{
    public class DataQueries
    {
        static string mailsPath = HttpContext.Current.Server.MapPath("~/Mails");

        public static string GetMailSubject(string mailID)
        {
            string subject = "";
            try
            {
                StreamReader sr = new StreamReader(mailsPath + '\\' + mailID + ".txt");
                subject = sr.ReadLine();
                sr.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }

            return subject;
        }

        public static string GetMailContent(string mailID)
        {
            string content = "";
            try
            {
                StreamReader sr = new StreamReader(mailsPath + '\\' + mailID + ".txt");
                sr.ReadLine();
                content = sr.ReadToEnd();
                sr.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }

            return content;
        }

    }
}